package com.kfm.web.controller.system;

import com.kfm.common.domain.model.Sale;
import com.kfm.common.domain.model.Saleroom;
import com.kfm.common.domain.response.Result;
import com.kfm.order.service.OrdersService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/statistics")
public class StatisticsController {

    // TODO 数据统计：销售额统计 商品预览统计 总浏览量统计

    @Resource
    private OrdersService ordersService;

    /**
     * 销售数量统计 按照商品分类
     */
    @RequestMapping("/sales")
    public Result sales() {
        List<Sale> sales = ordersService.selectSales();
        return sales == null ? Result.failure("查询失败") : Result.success("查询成功", sales);
    }

    /**
     * 销售额统计 按照每天统计销售额
     */
    @RequestMapping("/saleroom")
    public Result saleroom() {
        List<Saleroom> salerooms = ordersService.selectSaleroom();
        return salerooms == null ? Result.failure("查询失败") : Result.success("查询成功", salerooms);
    }
}
